interface ShowUp{
    void  表现 (String s);
}
class DOG implements ShowUp{
    public void  表现(String s){
        System.out.println(s);
    }
}
class CAT implements ShowUp{
    public void 表现(String s) {
        System.out.println(s);
    }
}
class Master {
    public void feed(Pet pet, Food food)
    {pet.eat(food);}
}
abstract class Pet {
    String name;
    public abstract void eat(Food food);
}
abstract class Food {
    private String name;
    public String getName() {
        return name;
    }
    public void setName(String name)
    {
        this.name = name;
    }
}
class Dog extends Pet {
    public Dog() {}
    public Dog(String name) {
        super();
        this.name = name;
    }
    @Override
    public void eat(Food food) {
        if(!(food instanceof Bone))
        {
            System.out.println("狗不吃" + food.getName() + "⻝物");
        }
    }
}
class Cat extends Pet {
    public Cat() {}
    public Cat(String name) {
        super();
        this.name = name;
    }
    @Override
    public void eat(Food food) {

        if(!(food instanceof Fish))
        {
            System.out.println("猫不吃" + food.getName() + "⻝物");
        }
    }
}
class Bone extends Food {
    public Bone() {}
    public Bone(String name) {
        super();
        super.setName(name);
    }
}
class Fish extends Food {
    public Fish() {}
    public Fish(String name) {
        super();
        super.setName(name);
    }
}



public class Text {
    public static void main(String[] args) {
        Pet pet;
        pet = new Dog("旺财");
        pet = new Cat("⼩花");
        ShowUp su;
        su = new DOG();
        su.表现("旺财转圈圈");
        su=new CAT();
        su.表现("小花喵喵叫");
        Master master = new
                Master();
        master.feed(pet, new
                Bone("⻣头"));
        master.feed(pet, new
                Fish("⻥"));
    }
}
